package main

import (
	"fmt"
	"strconv"
	"unicode/utf8"
)

func main() {
	name := "涂涛"
	fmt.Println(name[0])

	// 一个中午对应3个字节
	fmt.Println(name[0],strconv.FormatInt(int64(name[0]),2))
	fmt.Println(name[1],strconv.FormatInt(int64(name[1]),2))
	fmt.Println(name[2],strconv.FormatInt(int64(name[2]),2))


	fmt.Println(name[3],strconv.FormatInt(int64(name[0]),2))
	fmt.Println(name[4],strconv.FormatInt(int64(name[1]),2))
	fmt.Println(name[5],strconv.FormatInt(int64(name[2]),2))

	fmt.Println(len(name))

	bytes := []byte(name)
	fmt.Println(bytes)

	byteList := []byte{230,182, 130, 230, 182, 155}
	data := string(byteList)
	fmt.Println(data)
	runes := []rune(name)
	fmt.Println("runes",runes)

	fmt.Println(runes[0],strconv.FormatInt(int64(runes[0]),16))
	fmt.Println(runes[1],strconv.FormatInt(int64(runes[1]),16))


	s := string(runes)
	fmt.Println(s)

	i := []rune{runes[0], runes[1]}
	fmt.Println(string(i))

	// 长度处理
	countInString := utf8.RuneCountInString(s)
	fmt.Println(countInString)

}
